package cn.com.self.apis.member.service.impl;

import cn.com.self.apis.member.entity.UMemberInfoRelation;
import cn.com.self.apis.member.entity.UTalentRecommendation;
import cn.com.self.apis.member.entity.UTalentRecommendationVO;
import cn.com.self.apis.member.mapper.TalentRecommendationMapper;
import cn.com.self.apis.member.service.IMemberInfoRelationService;
import cn.com.self.apis.member.service.ITalentRecommendationService;
import cn.com.self.apis.portal.util.ICustomPage;
import cn.com.self.apis.portal.util.CustomPage;
import cn.com.selfsoft.smartcity.core.service.BaseServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TalentRecommendationServiceImpl extends BaseServiceImpl<UTalentRecommendation, String> implements ITalentRecommendationService {

    @Autowired
    private TalentRecommendationMapper talentRecommendationMapper;
    @Autowired
    private IMemberInfoRelationService memberRelationService;

    @Override
    public ICustomPage<UTalentRecommendationVO> getTalentRecommendationPage(Map<String, Object> queryParams, Pageable pageable) {
        CustomPage<UTalentRecommendationVO> page = new CustomPage<>(pageable.getPageNumber(),pageable.getPageSize());
        ICustomPage<UTalentRecommendationVO> result = talentRecommendationMapper.getTalentRecommendationPage(page,queryParams);
        for(UTalentRecommendationVO vo : result.getRows()){
            List<UMemberInfoRelation> list = memberRelationService.queryByMemberInfoId(vo.getMemberId().toString());
            vo.setMemberInfoRelationList(list);
        }
        return result;
    }
}
